﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using DevExpress.LookAndFeel;
using DevExpress.XtraSplashScreen;
using System.Diagnostics;
using Power;
using Beta;

namespace MainAPP
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                //检查一个进程运行
                Process thisProcess = Process.GetCurrentProcess();
                Process[] allProcesses = Process.GetProcessesByName(thisProcess.ProcessName);
                if (allProcesses.Length > 1)
                {
                    MessageBox.Show("程序已经运行!!","提示");
                    return;
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                                
                Application.SetCompatibleTextRenderingDefault(false);
                DevExpress.Skins.SkinManager.EnableFormSkins();
                DevExpress.UserSkins.BonusSkins.Register();
                UserLookAndFeel.Default.SetSkinStyle("Office 2010 Blue");
                #region Other Skin
                //UserLookAndFeel.Default.SetSkinStyle("Office 2007 Blue");
                //UserLookAndFeel.Default.SetSkinStyle("Office 2007 Black");
                //UserLookAndFeel.Default.SetSkinStyle("Office 2007 Silver");
                //UserLookAndFeel.Default.SetSkinStyle("Office 2007 Green");
                //UserLookAndFeel.Default.SetSkinStyle("Office 2007 Pink");
                //UserLookAndFeel.Default.SetSkinStyle("Coffee");
                //UserLookAndFeel.Default.SetSkinStyle("Liquid Sky");
                //UserLookAndFeel.Default.SetSkinStyle("London Liquid Sky");
                //UserLookAndFeel.Default.SetSkinStyle("Glass Oceans");
                //UserLookAndFeel.Default.SetSkinStyle("Stardust");
                //UserLookAndFeel.Default.SetSkinStyle("Xmas 2008 Blue");
                //UserLookAndFeel.Default.SetSkinStyle("Valentine");
                //UserLookAndFeel.Default.SetSkinStyle("McSkin");
                #endregion
                //show splash form
                SplashScreenManager.ShowForm(typeof(SplashScreen1));

                Power.Manager.Manager.BuildSystem();
                System.Threading.Thread.Sleep(1000);
                SplashScreenManager.CloseForm();

                //Power.UserInfo.UserInfo frm = new Power.UserInfo.UserInfo();
                //frm.ShowDialog();
                #region regist                
                //if (BetaUtil.IsExpire())
                //{
                //    MessageBox.Show("软件已经过期，有相应的功能无法启用。请联系工作人员!!", "警告");
                //}
                #endregion
                //Application.Run(new Power.MeterControl.MeterManual());
                Power.WinUI.LogOn logon = new Power.WinUI.LogOn();
                logon.ShowDialog();
                if (logon.DialogResult == DialogResult.OK)
                {
                    Application.Run(new MainForm());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("系统异常停止!! \n\t"+ex.ToString(),"错误");
            }
        }
    }
}
